#ifndef MOORE_1_H
#define MOORE_1_H


#include <vector>
#include "neighbourhoods.h"
#include "ca-pathfinding/grids/grid.h"

namespace mn
{

    std::vector<Tile*> neighbours(Grid* g,int i,int j)
    {

        std::vector<Tile*> v;
        int width=g->width();
        int height=g->height();

        if(i>0)v.push_back(g->tiles[i-1][j]);//N
        else v.push_back(nb::notExistingTile);
        if(j<width-1 && i>0)v.push_back(g->tiles[i-1][j+1]);//NE
        else v.push_back(nb::notExistingTile);
        if(j<width-1)v.push_back(g->tiles[i][j+1]);//E
        else v.push_back(nb::notExistingTile);
        if(j<width-1 && i<height-1)v.push_back(g->tiles[i+1][j+1]);//SE
        else v.push_back(nb::notExistingTile);
        if(i<height-1)v.push_back(g->tiles[i+1][j]);//S
        else v.push_back(nb::notExistingTile);
        if(j>0 && i<height-1)v.push_back(g->tiles[i+1][j-1]);//SW
        else v.push_back(nb::notExistingTile);
        if(j>0)v.push_back(g->tiles[i][j-1]);//W
        else v.push_back(nb::notExistingTile);
        if(i>0 && j>0)v.push_back(g->tiles[i-1][j-1]);//NW
        else v.push_back(nb::notExistingTile);
        return v;
    }

    std::vector<Tile*> neighbours(Grid* g,int i,int j,int r)
    {

        std::vector<Tile*> v;
        int width=g->width();
        int height=g->height();

        for(int y=i-r;i<=i+r;++i)
        {
            if(y<0)continue;
            if(y>height)break;
            for(int x=j-r;x<=j+r;++j)
            {
                if(x<0)continue;
                if(x>width)break;
                v.push_back(g->tiles[y][x]);
            }
        }
        return v;
    }

}
#endif // MOORE_1_H
